<template>
	<view class="full-page" v-if="totalPage">
		
	</view>
	<view class="content" v-else>
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="日志清单" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<view class="empytView" v-if="!list.total">
			<image :src="'/images/kong.png' | formatImgUrl" mode="widthFix" />
			<!-- <view>- 空列表 -</view> -->
		</view>
		<view class="xunli" v-for="(item,index) in logList">
			<view class="topbox" @click="shownei(item)">
				<view class="time">
					{{item.version_num}}
				</view>
				<view class="txt" :class="{active : item.id == selId}">
					{{item.create_time | formatTime}}
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" :class="{xuan : item.id == selId}" class="rarr" mode="">
				</image>
			</view>
			<view class="yinbox" v-if="item.id == selId">
				<view class="yintitle">
					{{item.name}}
				</view>
				<view class="dengtxt">
					{{item.create_time | formatTime}}
				</view>
				<view class="daotxt">
					<rich-text :nodes="item.row | filterRichText"></rich-text>
				</view>
			</view>
		</view>

		<!-- <view class="nomore" v-if="logList.length && list.current_page == list.last_page">
			没有更多了~
		</view> -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				page: 1,
				list: {},
				logList: [],
				selId: 0,
				totalPage: true
			}
		},
		onLoad() {},
		onShow() {
			this.getList()
		},
		// 上拉加载
		onReachBottom() {
			if (this.list.current_page < this.list.last_page) {
				this.page++; // 页数加一，加载下一页数据
				this.getList();
			}
		},
		methods: {
			getList() {
				this.$api.default.request('index/versionLog', {
					page: this.page
				}, 'POST', false).then((res) => {
					if (res.code) {
						this.list = res.data
						if (res.data.current_page > 1) {
							res.data.data.forEach((item) => {
								this.logList.push(item)
							})
						} else {
							this.logList = res.data.data
						}
						this.selId = this.logList[0].id
					}
					
					this.totalPage = false
				})
			},
			shownei(item) {
				this.selId = item.id == this.selId ? 0 : item.id
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(242, 245, 242, 1);
	}

	.content {
		padding-top: 20rpx;

		.xunli {
			background-color: #ffffff;
			margin-bottom: 20rpx;

			.topbox {
				padding: 40rpx 68rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.time {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					flex-shrink: 0;
				}

				.txt {
					flex-grow: 1;
					font-size: 28rpx;
					font-weight: normal;
					text-align: right;
					color: #999999;
					padding: 0 20rpx;
				}

				.active {
					color: #45C4B0;
				}

				.rarr {
					width: 40rpx;
					height: 40rpx;
					flex-shrink: 0;
				}

				.xuan {
					transform: rotate(90deg);
				}
			}

			.yinbox {
				box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.07) inset;
				padding: 40rpx 68rpx;

				.yintitle {
					font-size: 32rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
				}

				.dengtxt {
					font-size: 24rpx;
					font-weight: normal;
					letter-spacing: 0em;
					color: #999999;
					padding-bottom: 12rpx;
				}

				.daotxt {
					font-size: 24rpx;
					font-weight: normal;
					letter-spacing: 0em;
					color: #3D3D3D;
					line-height: 34rpx;
				}
			}
		}
	}
</style>